<?php

/**
 * +------------IMBA收集反馈数据的操作---------------+
 * +-------------------------------------------------+
 * +--------------用于提供内部接口-------------------+
 * +-------------------------------------------------+
 * +-@author -+
 * +-------------------------------------------------+
 */

namespace Api\Event;

class FeedbackEvent extends BaseEvent
{
	/**
	 * 添加新的反馈
	 *
	 * @param int     $uid     操作的用户标识
	 * @param string  $content 反馈内容
	 * @return bool
	 */
	public function add( $uid, $type, $content, $platform) {
		if ( !$uid || !$content) {
			return;
		}
		$service = D( 'Common/Feedback', 'Service' );
		$map = array(
			'uid'=>intval( $uid ),
			'type'=>$type,
			'platform'=>$platform,
			'content'=>$content,
			'create_time'=>NOW_TIME,
			'status'=>0
		);
		return $service->add( $map );
	}

	/**
	 * 查询最新的反馈
	 *
	 * @param int     $uid     操作的用户标识
	 * @param string  $content 反馈内容
	 * @return string
	 */
	public function info( $uid ) {
		if ( !$uid ) {
			return;
		}
		$service = D( 'Common/Feedback', 'Service' );
		$map = array(
			'uid'=>intval( $uid )
		);
		return $service->where( $map )->order('create_time DESC')->field('content')->find();
	}
}